import { RouteConfig } from 'vue-router'

const routes: Array<RouteConfig> = [
  {
    path: '/',
    component: () => import(/* webpackChunkName: "layout" */ '@/views/layout/index.vue'),
    meta: { pid: '/' },
    children: [
      {
        path: 'recent',
        name: 'recent',
        props: ({ params = {} }) => ({ ...params }),
        component: () => import(/* webpackChunkName: "recent" */'@/views/pages/recent/index.vue'),
        meta: { pid: '/recent' }
      },
      {
        path: 'docs',
        name: 'docs',
        props: ({ params = {}, query = {} }) => ({ ...params, ...query }),
        component: () => import(/* webpackChunkName: "docs" */'@/views/pages/docs/index.vue'),
        meta: { pid: '/docs' }
      },
      {
        path: 'ent/:entId/docs',
        name: 'ent.docs',
        props: ({ params = {}, query = {} }) => ({ ...params, ...query }),
        component: () => import(/* webpackChunkName: "docs" */'@/views/pages/docs/index.vue'),
        meta: { pid: '/docs' }
      },
      {
        path: 'star',
        name: 'star',
        props: ({ params = {} }) => ({ ...params }),
        component: () => import(/* webpackChunkName: "star" */'@/views/pages/star/index.vue'),
        meta: { pid: '/star' }
      },
      {
        path: 'trash',
        name: 'trash',
        props: ({ params = {} }) => ({ ...params }),
        component: () => import(/* webpackChunkName: "trash" */'@/views/pages/trash/index.vue'),
        meta: { pid: '/trash' }
      },
      {
        path: 'search',
        name: 'search',
        props: ({ params = {}, query = {} }) => ({ ...params, ...query }),
        component: () => import(/* webpackChunkName: "search" */'@/views/pages/search/index.vue'),
        meta: { pid: '/search' }
      },
      {
        path: 'flow',
        name: 'flow',
        props: ({ params = {} }) => ({ ...params }),
        component: () => import(/* webpackChunkName: "flow" */'@/views/pages/flow/index.vue'),
        meta: { pid: '/flow' },
        redirect: '/flow/todo',
        children: [
          {
            path: 'todo',
            name: 'flow.todo',
            props: ({ params = {} }) => ({ ...params }),
            component: () => import(/* webpackChunkName: "flow.todo" */'@/views/pages/flow/todo/index.vue'),
            meta: { pid: '/flow' }
          },
          {
            path: 'done',
            name: 'flow.done',
            props: ({ params = {} }) => ({ ...params }),
            component: () => import(/* webpackChunkName: "flow.done" */'@/views/pages/flow/done/index.vue'),
            meta: { pid: '/flow' }
          },
          {
            path: 'apply',
            name: 'flow.apply',
            props: ({ params = {} }) => ({ ...params }),
            component: () => import(/* webpackChunkName: "flow.done" */'@/views/pages/flow/apply/index.vue'),
            meta: { pid: '/flow' }
          }
        ]
      },
      {
        path: 'flow/:id/detail',
        name: 'flow.detail',
        props: ({ params = {} }) => ({ ...params }),
        component: () => import(/* webpackChunkName: "flow.detail" */'@/views/pages/flow/detail/index.vue'),
        meta: { pid: '/flow' }
      },
      {
        path: 'flow/:id/audit',
        name: 'flow.audit',
        props: ({ params = {}, query = {} }) => ({ ...params, ...query }),
        component: () => import(/* webpackChunkName: "flow.audit" */'@/views/pages/flow/audit/index.vue'),
        meta: { pid: '/flow' }
      },
      {
        path: 'local',
        name: 'local',
        props: ({ params = {}, query = {} }) => ({ ...params, ...query }),
        component: () => import(/* webpackChunkName: "local" */'@/views/pages/local/index.vue'),
        meta: { pid: '/local' }
      },
      // 暂时屏蔽 待完善
      // {
      //   path: 'flow',
      //   name: 'flow',
      //   props: ({ params = {} }) => ({ ...params }),
      //   component: () => import(/* webpackChunkName: "flow" */'@/views/pages/flow/index.vue'),
      //   meta: { pid: '/flow' },
      //   redirect: '/flow/todo',
      //   children: [
      //     {
      //       path: 'todo',
      //       name: 'flow.todo',
      //       props: ({ params = {} }) => ({ ...params }),
      //       component: () => import(/* webpackChunkName: "flow.todo" */'@/views/pages/flow/todo/index.vue'),
      //       meta: { pid: '/flow' }
      //     },
      //     {
      //       path: 'done',
      //       name: 'flow.done',
      //       props: ({ params = {} }) => ({ ...params }),
      //       component: () => import(/* webpackChunkName: "flow.donw" */'@/views/pages/flow/done/index.vue'),
      //       meta: { pid: '/flow' }
      //     }
      //   ]
      // },
      {
        path: 'trash/user',
        name: 'trash.user',
        props: ({ params = {} }) => ({ ...params, type: 'user' }),
        component: () => import(/* webpackChunkName: "trash.user" */'@/views/pages/trash/bin/index.vue'),
        meta: { pid: '/trash' }
      },
      {
        path: 'trash/enterprise/:id',
        name: 'trash.enterprise',
        props: ({ params = {} }) => ({ ...params, type: 'enterprise' }),
        component: () => import(/* webpackChunkName: "trash.enterprise" */'@/views/pages/trash/bin/index.vue'),
        meta: { pid: '/trash' }
      },
      {
        path: 'message',
        name: 'message',
        props: ({ params = {} }) => ({ ...params }),
        component: () => import(/* webpackChunkName: "trash.message" */'@/views/pages/message/index.vue'),
        meta: { pid: '/message' }
      },
      {
        path: 'download',
        name: 'download',
        props: ({ params = {} }) => ({ ...params }),
        component: () => import(/* webpackChunkName: "download" */'@/views/pages/download/index.vue'),
        meta: { pid: '/download' }
      },
      {
        path: 'download/:id/detail',
        name: 'downloadDetail',
        props: ({ params = {} }) => ({ ...params }),
        component: () => import(/* webpackChunkName: "download" */'@/views/pages/download/detail/index.vue'),
        meta: { pid: '/download' }
      }
    ]
  },
  {
    path: '/after-authorize',
    name: 'after-authorize',
    props: ({ params = {}, query = {} }) => ({ ...params, ...query }),
    component: () => import(/* webpackChunkName: "after-authorize" */'@/views/pages/after-authorize/index.vue')
  },
  {
    path: '/forgot-password',
    name: 'forgot-password',
    props: ({ params = {}, query = {} }) => ({ ...params, ...query }),
    component: () => import(/* webpackChunkName: "forgot-password" */'@/views/pages/forgot-password/index.vue')
  },
  {
    path: '/login',
    name: 'login',
    props: ({ params = {} }) => ({ ...params }),
    component: () => import(/* webpackChunkName: "login" */'@/views/login/index.vue')
  },
  {
    path: '/preview/:id',
    name: 'preview',
    props: ({ params = {}, query = {} }) => ({ ...params, ...query }),
    component: () => import(/* webpackChunkName: "preview" */'@/views/pages/preview/index.vue'),
    meta: { pid: '/preview' }
  },
  {
    path: '/editor/:id',
    name: 'editor',
    props: ({ params = {}, query = {} }) => ({ ...params, ...query }),
    component: () => import(/* webpackChunkName: "editor" */'@/views/pages/editor/index.vue'),
    meta: { pid: '/editor' }
  },
  {
    path: '/s/:id',
    name: 'share',
    props: ({ params = {}, query = {} }) => ({ ...params, ...query }),
    component: () => import(/* webpackChunkName: "share" */'@/views/share/index.vue')
  },
  {
    path: '/s/p/:id',
    name: 'share-preview',
    props: ({ params = {}, query = {} }) => ({ ...params, ...query }),
    component: () => import(/* webpackChunkName: "share.preview" */'@/views/share-preview/index.vue')
  },
  {
    path: '/config',
    name: 'config',
    props: ({ params = {}, query = {} }) => ({ ...params, ...query }),
    component: () => import(/* webpackChunkName: "share.config" */'@/views/config/index.vue')
  },
  {
    path: '/error/:code',
    name: 'error',
    props: ({ params = {} }) => ({ ...params }),
    component: () => import(/* webpackChunkName: "error" */'@/views/error/index.vue'),
    meta: { pid: '/recent' }
  },
  {
    path: '',
    redirect: '/'
  },
  {
    path: '*',
    redirect: '/error/404'
  }
]

export default routes
